package com.dcz.fileportal.options;

import android.content.Context;

import androidx.annotation.NonNull;

import com.dcz.fileportal.network.ProgressListener;
import com.dcz.fileportal.network.callbacks.FileUploadResultCallback;

import java.io.File;
import java.util.HashMap;

public class UploadOptions {

    private final File file;
    private final String api;
    private final HashMap<String,String> headerMap;
    private final HashMap<String,String> map;
    private final FileUploadResultCallback fileUploadResultCallback;
    private final ProgressListener progressListener;

    private UploadOptions(Builder builder) {
        this.file = builder.getFile();
        this.fileUploadResultCallback = builder.getFileUploadResultCallback();
        this.progressListener = builder.getProgressListener();
        this.map = builder.getParamMap();
        this.headerMap = builder.getHeaderMap();
        this.api = builder.getApi();
    }

    public File getFile() {
        return file;
    }

    public String getApi() {
        return api;
    }
    public HashMap<String,String> getMap() {
        return map;
    }

    public HashMap<String,String> getHeaderMap() {
        return headerMap;
    }

    public FileUploadResultCallback getFileUploadResultCallback() {
        return fileUploadResultCallback;
    }

    public ProgressListener getProgressListener() {
        return progressListener;
    }

    public static class Builder {

        private final Context context;
        private final File file;
        private final String api;
        private HashMap<String,String> HeaderMap;
        private HashMap<String,String> map;
        private FileUploadResultCallback fileUploadResultCallback = null;
        private ProgressListener progressListener = null;

        /**
         * @param context current context.
         * @param file    The file to upload.
         */
        public Builder(@NonNull final Context context, @NonNull File file, @NonNull String api) {
            this.context = context;
            this.file = file;
            this.api = api;
        }

        public Context getContext() {
            return context;
        }

        public File getFile() {
            return file;
        }

        public String getApi() {
            return api;
        }

        public Builder setParamMap(HashMap<String,String> map) {
            this.map = map;
            return this;
        }

        public HashMap<String,String> getParamMap() {
            return map;
        }

        public Builder setHeaderMap(HashMap<String,String> map) {
            this.HeaderMap = map;
            return this;
        }

        public HashMap<String,String> getHeaderMap() {
            return HeaderMap;
        }



        public FileUploadResultCallback getFileUploadResultCallback() {
            return fileUploadResultCallback;
        }

        public Builder setFileUploadResultCallback(FileUploadResultCallback fileUploadResultCallback) {
            this.fileUploadResultCallback = fileUploadResultCallback;
            return this;
        }

        public ProgressListener getProgressListener() {
            return progressListener;
        }

        public Builder setProgressListener(ProgressListener progressListener) {
            this.progressListener = progressListener;
            return this;
        }

        public UploadOptions build() {
            return new UploadOptions(this);
        }
    }
}
